//通用分享JS
export default {
	data() {
		return {

		}
	},
	filters: {
		million(value) { //过万处理
			let num;
			if (value > 9999) { //大于9999显示x.xx万
				num = (Math.floor(value / 1000) / 10) + 'w+';
			} else if (value < 9999 && value >= 0) {
				num = value
			}
			return num;
		},
	},
	onLoad(options) {
		if (options.referee_id) {
			uni.setStorageSync("referee_id", options.referee_id);
		}
	},
	onShareAppMessage(res) {
		if (res.from === 'button') { // 来自页面内分享按钮
			// console.log(res.target)
		}
		let pages = getCurrentPages();
		let routerUrl = pages[pages.length - 1].$page.fullPath //获取当前页的路径
		let path = ""
		if (routerUrl.indexOf('?') != -1) {
			path = `${routerUrl}&referee_id=${uni.getStorageSync('user').id}`
		} else {
			path = `${routerUrl}?referee_id=${uni.getStorageSync('user').id}`
		}
		// console.log(path);
		return {
			title: "快来看看这个宝藏小程序！",
			imageUrl: "https://miaoyao-oss.oss-cn-hangzhou.aliyuncs.com/profitTool/fxhb.png",
			path: path,
			success(res) {},
			fail(res) {}
		}
	},
	// #ifdef MP-WEIXIN
	onShareTimeline(res) {
		if (res.from === 'button') { // 来自页面内分享按钮
			// console.log(res.target)
		}
		let pages = getCurrentPages();
		let routerUrl = pages[pages.length - 1].$page.fullPath //获取当前页的路径
		let path = ""
		if (routerUrl.indexOf('?') != -1) {
			path = `${routerUrl}&referee_id=${uni.getStorageSync('user').id}`
		} else {
			path = `${routerUrl}?referee_id=${uni.getStorageSync('user').id}`
		}
		// console.log(path);
		return {
			title: "快来看看这个宝藏小程序！",
			imageUrl: "https://miaoyao-oss.oss-cn-hangzhou.aliyuncs.com/profitTool/fxhb.png",
			path: path,
			success(res) {},
			fail(res) {}
		}
	}
	// #endif
}